<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>AP费用核销支付凭证</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
  <!-- <link rel="shortcut icon" href="favicon.ico"> -->
      <!-- <link rel="shortcut icon" href="favicon.ico"> -->
   <link href="__STATIC__/layout/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__STATIC__/layout/css/font-awesome.css?v=4.4.0" rel="stylesheet">
     <link href="__STATIC__/layout/css/plugins/summernote/summernote.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/plugins/summernote/summernote-bs3.css" rel="stylesheet">
     <link rel="stylesheet" type="text/css" href="__STATIC__/layout/css/plugins/webuploader/webuploader.css">
    <link rel="stylesheet" type="text/css" href="__STATIC__/layout/css/demo/webuploader-demo.css">
    <!-- jqgrid-->
    <link href="__STATIC__/layout/css/animate.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="__STATIC__/layout/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/gyq.css" rel="stylesheet">
    <link rel="stylesheet" href="__STATIC__/layout/css/demo.css" type="text/css">
</head>

<body style="color:#333;padding:3px;font-size:13px" class="x_sorll">
    <!-- 标题 -->
    <div class="page-heade">
      <h2 class="title_color text-center">AP费用核销支付凭证</h2>
    </div>
    <!-- 标题 -->
    <form id="f1">
    <div class="contact-box" style="padding: 8px">
    <input type="hidden" name="state" id="state"/>
    <input type="hidden" name="hid" value="{$hid}"/>
        <button class="btn btn-info" type="button" onclick="daochuhexiao({$hid})">导出Excel</button>
    </div>
     <table class="table table-bordered text-center bud_hei" style="margin-bottom: 0">
        <tr>
            <td style="min-width: 120px;width: 120px">申请人</td>
            <td class="text-left"><a href="javascript:;">{$apply.cname}</a></td>
            <td style="min-width: 120px;width: 120px">申请人所在部门/职位</td>
            <td class="text-left">{$apply.de_name}/{$apply.job_name}</td>
            <td style="min-width: 120px;width: 120px">编号</td>
            <td class="text-left">{$apply.no}</td>
            <td style="min-width: 120px;width: 120px">提交时间</td>
            <td class="text-left">{$apply.created_on}</td>
        </tr>
        <tr>
            <td style="min-width: 120px;width: 120px">供应商名称</td>
            <td class="text-left" colspan="7">{$gys_str}</td>
        </tr>
        <table class="table-bordered table">
             <tr>
            <td style="border-top: 0"><span class="colorRed font-bold">温馨提示：请在发票粘贴联上注明此申请单编号：{$apply.no}</span><a href="javascript:;">点击查看图例</a></td>
        </tr>
        </table>
    </table>
      <table class="table table-striped table-bordered bud_hei text-center">
        <tr class="info">
            <td rowspan="2">序号</td>
            <td rowspan="2">明细编号</td>
            <td rowspan="2">原申请人</td>
            <td rowspan="2">原申请文件</td>
            <td rowspan="2">原明细编号</td>
            <td rowspan="2">渠道类型</td>
            <td rowspan="2">供应商名称</td>
            <td rowspan="2">品牌</td>
            <td rowspan="2">三级费用科目</td>
            <td colspan="3">实际投入</td>
            <td colspan="8">本次申请核销</td>
            <td rowspan="2">活动开始日期</td>
            <td rowspan="2">支付方式</td>
            <td rowspan="2">本次支付方式</td>
            <td rowspan="2">备注</td>
            <td rowspan="2">操作记录</td>
            
        </tr>
         <tr class="info">
            <td>实际投入金额</td>
            <td>已核销金额</td>
            <td>未核销金额</td>
            <td>未税核销金额</td>
            <td>有无发票</td>
            <td>发票号</td>
            <td>是否增值税(可抵扣)</td>
            <td>税率</td>
            <td>税金</td>
            <td>含税核销金额</td>
            <td>实际核销金额</td>
        </tr>
        {volist name="applyde" id="vo"}
            <tr>
                 <td>{$i}<input type="hidden" name="did[]" value="{$vo.ahdid}"/><input type="hidden" name="yuan_hexiao[]" value="{$vo.hexiao_weishui}"/><input type="hidden" name="detail_id[]" value="{$vo.detail_id}"/></td>
                <td>{$vo.he_no}_{$vo.he_detail_no}</td>
                <td class="text-left">{$vo.cname}</td>
                <td><a href="{:url('apply_de')}?aid={$vo.apid}" class="J_menuItem" title="AP费用申请">{$vo.no}</a></td>
                 <td>{$vo.no}_{$vo.detail_no}<a href="{:url('mingxijuece')}?did={$vo.apdid}" title="决策依据" class="J_menuItem" ><span style="display: none;">决策依据</span><span class="glyphicon glyphicon-zoom-in fangda" aria-hidden="true" style="display: inline-block;"></span></a></td>
                 <td>{$vo.channel}</td>
                 <td>{$vo.gys_name}</td><td>{$vo.brand}</td><td>{$vo.kemu3}</td>
                 <td class="num2">{$vo.hanshui}</td> <td class="num2">{$vo.hexiao}</td><td class="num2">{$vo.weihe}</td>
                 
                 <td><input type="text" class="num2i heweishui" name="hexiao_weishui[]" max="{$vo.max}" value="{$vo.hexiao_weishui}"></td>
                 <td>
                  <div class="form-group radioDiv">
                  <label>
                    <input type="radio" name="isfa{$i}" class="fashi" {if $vo.has_fp==1} checked {/if} value="1" >有
                  </label>
                   <label>
                        <input type="radio" name="isfa{$i}" class="fafou" {if $vo.has_fp==0} checked {/if}  value="0">无
                  </label>
                  <input type="hidden" name="isfa[]" class="isfa" value="{$vo.has_fp}"/>
                  </div>
                  </td>
                 <td><input type="text" name="fp_no[]" {if $vo.has_fp==0} readonly {/if} value="{$vo.fp_no}"></td>
                 <td>
                    <div class="form-group">
                    <label>
                      <input type="radio" name="dikou{$i}" class="dikoushi" {if $vo.dikou==1} checked {/if} value="1" >是
                    </label>
                     <label>
                          <input type="radio" name="dikou{$i}" class="dikoufou"{if $vo.dikou==0} checked {/if} checked>否
                    </label>
                    <input type="hidden" name="isdi[]" class="isdi" value="{$vo.dikou}"/>
                  </div>
                 </td>
                 <td><input type="text" class="num2i shuilv" name="hexiao_shuilv[]" value="{$vo.hexiao_shuilv}">%</td><td class="num2">{$vo.shuijin}</td><td class="num2">{$vo.he_hanshui}</td>
                 <td class="num2">{$vo.he_hanshui}</td> <td>{$vo.start_time}</td><td>{$vo.zffs}</td>
                 <td><select name="zfid[]">
                  {volist name="pay" id="p"}
                    {if $vo.bczffs==$p.id}
                    <option value="{$p.id}" selected>{$p.title}</option>
                    {else/}
                    <option value="{$p.id}">{$p.title}</option>
                    {/if}
                  {/volist}
                </select></td>
                 <td>{$vo.beizhu}</td><td></td>
            </tr>
        {/volist}
        
        <tr class="trTotal1 font-bold text-right">
            <td colspan="9" class="text-right font-bold">合计</td>
            <td class="num2">{$all.hanshui}</td>
            <td class="num2">{$all.hexiao}</td>
            <td class="num2 whzong">{$all.weihe}</td>
            <td class="num2 wszonge">{$all.hexiao_weishui}</td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td class="num2 sjzonge">{$all.shuijin}</td>
            <td class="num2 hszong">{$all.he_hanshui}</td>
            <td class="num2 hszong">{$all.he_hanshui}</td>
            <td colspan="5"></td>
        </tr>
        <tr>
        <td colspan="2">备注</td>
        <td colspan="25"><textarea name="remark" style="width: 90%;height: 50px">{$apply.remark}</textarea></td>
        </tr>
        </table>
        <table class="table table-bordered text-left bud_hei">
            <tr>
                <th class="text-left info">支付信息</th>
            </tr>
            <tr>
                <td>总含税金额：<span class="num2 font-bold">{$all.he_hanshui}</span>元 已支付金额：<span class="num2 font-bold">{$all.zhifu_jine}</span>元 未支付金额：<span class="num2 font-bold">{$all.weifu}</span>元</td>
            </tr>
            {volist name="zhifus" id="zf"}
            <tr>
                <td>支付凭证:{$zf.zfpz}&nbsp;;&nbsp;支付人:{$zf.cname}&nbsp;;&nbsp;支付时间:{$zf.zhifu_day}&nbsp;;&nbsp;支付金额:<span class="num2 font-bold">{$zf.zfjin}</span>元&nbsp;;&nbsp;支付备注:{$zf.remark}</td>
            </tr>
            {/volist}
        </table>
     <table class="table table-bordered text-left bud_hei">
            <tr class="info">
                <th class="text-left font-bold">审批意见</th>
            </tr>
            {volist name="logs" id="l"}
          <tr>
              <td>{$l.USERNAME} 审批动作：{$l.MEMO}；审批意见：{if $l.COMMENTS}{$l.COMMENTS}{else/}无{/if}(审批时间：{$l.ACTIONTIME})</td>
          </tr>
          
          {/volist}
      </table>
        <div class="form-group white-bg" style="margin:20px 10px 20px 20px;">
            <div id="uploader" class="wu-example">
                <!--用来存放文件信息-->
                <div id="thelist" class="uploader-list">
                   {volist name="fujian" id="fo"}
                        <h4>{$fo.file_name}</h4>
                   {/volist}
                </div>
                <div class="btns">
                    <div id="picker">选择文件</div>
                    <button id="ctlBtn" class="btn btn-default">开始上传</button>
                </div>
                <input type="hidden" name="attach" id="attach" {if $fujian} value="{$apply.fujian}" {/if} >
            </div>
            <span>注：最多上传15个文件，每个文件小于50M,支持格式：</span><br>jpg,bnp,gif,png,jpeg,tif,raw,doc,docx,xls,xlsx,ppt,pptx,txt,pdf,rar,zip,mp4,avi,rmvb,rm,mid,3gp,AVI,3GP,,mpg,mp3,wma,wav
        </div>
         <div class="row text-center no-padding">
   {if $apply.state==2}
                <input type="hidden" id="nodeKey" name="nodeKey"/>
                  <input type="hidden" id="selectId" name="selectId"/>
                  <input type="hidden" id="selectName" name="selectName"/>
                    {volist name="btn.nextNodes" id="b"}
                      {if $b.nodeName=='结束'}
                      <input type="button" class="btn-danger btn" onclick="zuofei('{$b.nodeKey}','{$b.selectId}','{$b.selectName}')" value="点此作废"/>
                      {else/}
                      <input type="button" class="btn-info btn" onclick="baocun('{$b.nodeKey}','{$b.selectId}','{$b.selectName}')" value="保存并提交工作流"/>
                      {/if}
                    {/volist}
   {else/}
      <input type="button" class="btn btn-primary" onclick="tijiao(1)" value="保存为草稿"/>
      <input type="button" class="btn btn-warning" onclick="tijiao(3)" value="保存并提交流程"/>
    {/if}
      <button  class="btn btn-info" type="button" onclick="back()">返回</button>
    
    </div>
      <br/> <br/> <br/> <br/>
      {if condition="$apply.is_shengxiao eq 1"}
      <div class="SuccessImg font-bold">
        已&nbsp;生&nbsp;效
      </div>
      {/if}

</form>
 <div class="footer fixed_full text-center" id="fixBG">
        本次核销未税金额合计：<strong class="colorRed"><span class="num2 font-bold wszonge" style="font-size:14px">{$all.hexiao_weishui}</span>元</strong>;税金合计：<strong class="colorRed"><span class="num2 font-bold sjzonge" style="font-size:14px">{$all.shuijin}</span>元</strong>;含税金额合计：<strong class="colorRed"><span class="num2 font-bold hszong" style="font-size:14px">{$all.he_hanshui}</span>元</strong>;实际金额合计：<strong class="colorRed"><span class="num2 font-bold hszong" style="font-size:14px">{$all.he_hanshui}</span>元</strong>;
    </div>
    <!-- 全局js -->
     <script src="__STATIC__/layout/js/jquery.min.js?v=2.1.4"></script>
    <script src="__STATIC__/layout/js/bootstrap.min.js?v=3.3.6"></script>
    <!-- <script src="js/plugins/metisMenu/jquery.metisMenu.js"></script> -->
    <script src="__STATIC__/layout/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
   <script src="__STATIC__/layout/js/plugins/layer/laydate/laydate.js"></script>
     <script src="__STATIC__/layout/js/plugins/sweetalert/sweetalert.min.js"></script>
         <script src="__STATIC__/layout/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="__STATIC__/layout/js/plugins/summernote/summernote.min.js"></script>
<script src="__STATIC__/layout/js/plugins/summernote/summernote-zh-CN.js"></script>
<script src="__STATIC__/layout/js/plugins/suggest/bootstrap-suggest.min.js"></script>
 <script src="__STATIC__/layout/js/common.js"></script>
  <script src="__STATIC__/layout/js/plugins/layer/layer.min.js"></script>

  <script src="__STATIC__/layout/js/contabs_sub.js"></script>
  <script>
  var fr={$from};
   function tijiao(state){
    $("#state").val(state);
     $.ajax({
          cache: true,
          type: "POST",
          url:"{:url('hxxiugaichuli')}",
          data:$('#f1').serialize(),// 你的formid
          async: false,
          error: function(request) {
            alert("Connection error");
          },
          success: function(data) {
           // alert(data);
            //var res=JSON.parse(data);
                    var res1=JSON.parse(data);
                            if(res1["state"]==1){
                              swal({
                                title: "完成",
                                text: "操作已成功",
                                type: "success"
                                },function(){
                                   if(fr==1)
                                        location.href="{:url('apcvcation')}"
                                    else
                                        location.href="{:url('Workflowdb/index')}"
                                  //parent.layer.close(parent.layer.getFrameIndex(window.name))
                                  //
                                });

                          }else{
                            swal({
                            title: "错误",
                            text:  res1["msg"],
                            type: "warning"
                            });
                          }     
          }
        });
  }
    function baocun(nodeKey,selectId,selectName){
  $("#nodeKey").val(nodeKey)
  $("#selectId").val(selectId)
  $("#selectName").val(selectName)
   $.ajax({
          cache: true,
          type: "POST",
          url:"{:url('hxbaocunchuli')}",
          data:$('#f1').serialize(),// 你的formid
          async: false,
          error: function(request) {
            alert("Connection error");
          },
          success: function(data) {
            //alert(data);
            //var res=JSON.parse(data);
                    var res1=JSON.parse(data);
                            if(res1["state"]==1){
                              swal({
                                title: "完成",
                                text: "操作已成功",
                                type: "success"
                                },function(){
                                  if(fr==1)
                                        location.href="{:url('apcvcation')}"
                                  else
                                        location.href="{:url('Workflowdb/index')}"
                                });

                          }else{
                            swal({
                            title: "错误",
                            text:  res1["msg"],
                            type: "warning"
                            });
                          }           
          }
        });
}
      function zuofei(nodeKey,selectId,selectName){
  $("#nodeKey").val(nodeKey)
  $("#selectId").val(selectId)
  $("#selectName").val(selectName)
   $.ajax({
          cache: true,
          type: "POST",
          url:"{:url('hxzuofeichuli')}",
          data:$('#f1').serialize(),// 你的formid
          async: false,
          error: function(request) {
            alert("Connection error");
          },
          success: function(data) {
           // alert(data);
            //var res=JSON.parse(data);
                    var res1=JSON.parse(data);
                            if(res1["state"]==1){
                              swal({
                                title: "完成",
                                text: "操作已成功",
                                type: "success"
                                },function(){
                                   if(fr==1)
                                        location.href="{:url('apcvcation')}"
                                    else
                                        location.href="{:url('Workflowdb/index')}"
                                  //parent.layer.close(parent.layer.getFrameIndex(window.name))
                                  //
                                });

                          }else{
                            swal({
                            title: "错误",
                            text:  res1["msg"],
                            type: "warning"
                            });
                          }         
          }
        });
}
   function back(){
            if(fr==1)
                 location.href="{:url('apcvcation')}"
            else
                location.href="{:url('Workflowdb/index')}"
        }
   function jisuanzongshu(){
         var zongweishui=0;
          var zonghanshui=0;
          var zongshuijin=0;
          var weihezong=0;
        $(".heweishui").each(function(){
         
           
              zongweishui+=parseFloat(parseFloat($(this).val()).toFixed(2));
               zonghanshui+=parseFloat(parseFloat($(this).parent().next().next().next().next().next().next().html()).toFixed(2));
               zongshuijin+=parseFloat(parseFloat($(this).parent().next().next().next().next().next().html()).toFixed(2));
               weihezong+=parseFloat(parseFloat($(this).parent().prev().html()).toFixed(2));
            
        })
        $(".sjzonge").html(zongshuijin.toFixed(2));
         $(".hszong").html(zonghanshui.toFixed(2));
        $(".wszonge").html(zongweishui.toFixed(2));
        $(".whzong").html(weihezong.toFixed(2))

     }
  $(".shuilv").blur(function(){
          if(isNaN(parseFloat($(this).val()))){
              $(this).val("0.00");
            }else{
              $(this).val(parseFloat($(this).val()).toFixed(2));
            }
         var price=$(this).parent().prev().prev().prev().prev().children().val();
        //alert(price);
          if(price!=""){
            price=parseFloat(price);
            var shuilv=parseFloat($(this).val());
            var shuijin=(price*shuilv/100).toFixed(2);
            var zonge=(price+parseFloat(shuijin)).toFixed(2);
            $(this).parent().next().html(shuijin);
             $(this).parent().next().next().html(zonge);
          }
         jisuanzongshu();
     })
    $(".heweishui").blur(function(){
         if(isNaN(parseFloat($(this).val()))){
              $(this).val("0.00");
            }else{
              var max=parseFloat($(this).attr("max"));
              if(parseFloat($(this).val())>max){
                var res=max;
              }else{
                var res=parseFloat($(this).val())
              }
              var weihe=max-res;
              $(this).parent().prev().html(weihe.toFixed(2))
              $(this).val(res.toFixed(2));
            }
          var shuilv=$(this).parent().next().next().next().next().children().val();
          if(shuilv!=""){
            shuilv=parseFloat(shuilv);
            var price=parseFloat($(this).val());
            var shuijin=(price*shuilv/100).toFixed(2);
            var zonge=(price+parseFloat(shuijin)).toFixed(2);
            $(this).parent().next().next().next().next().next().html(shuijin);
             $(this).parent().next().next().next().next().next().next().html(zonge);
          }
          jisuanzongshu();
     })
   $(".fafou").change(function(){
        if($(this).prop("checked")){
          $(this).parent().parent().parent().next().children().val("").prop("readonly",true);
          $(this).parent().next().val(0);
        }
     })
      $(".fashi").change(function(){
        if($(this).prop("checked")){
          $(this).parent().parent().parent().next().children().val("").prop("readonly",false);
           $(this).parent().next().next().val(1);
        }
     })
       $(".dikoufou").change(function(){
        if($(this).prop("checked")){
          
          $(this).parent().next().val(0);
        }
     })
      $(".dikoushi").change(function(){
        if($(this).prop("checked")){
         
           $(this).parent().next().next().val(1);
        }
     })
   function down(id){
    window.open("{:url('download_fujian')}?fid="+id)
  }
  function daochuhexiao(hid){
    location.href="{:url('daochuhexiao')}?hid="+hid;
  }
    $(".num2").each(function(){
                if(!isNaN(parseFloat($(this).html())))
                 var num=parseFloat($(this).html()).toFixed(2);
                else
                    var num="0.00";
                $(this).html(num);
            })
  </script>
       <!-- Web Uploader -->
<script type="text/javascript">
    // 添加全局站点信息
    var BASE_URL = '__STATIC__/layout/js/plugins/webuploader';
</script>
<script src="__STATIC__/layout/js/plugins/webuploader/webuploader.min.js"></script>
<script type="text/javascript">
   // 文件上传
    jQuery(function() {
        var $ = jQuery,
            $list = $('#thelist'),
            $btn = $('#ctlBtn'),
            state = 'pending',
            uploader;

        var ids = [{if $fujian} value="{$apply.fujian}" {/if}];
        uploader = WebUploader.create({

            // 不压缩image
            resize: false,

            // swf文件路径
            swf: BASE_URL + '/js/Uploader.swf',

            // 文件接收服务端。
            server: '{:url("upload/fileupload")}',

            // 选择文件的按钮。可选。
            // 内部根据当前运行是创建，可能是input元素，也可能是flash.
            pick: '#picker'
        });

        // 当有文件添加进来的时候
        uploader.on( 'fileQueued', function( file ) {
            $list.append( '<div id="' + file.id + '" class="item">' +
                '<h4 class="info">' + file.name + '</h4>' +
                '<p class="state">等待上传...</p>' +
                '</div>' );
        });

        // 文件上传过程中创建进度条实时显示。
        uploader.on( 'uploadProgress', function( file, percentage ) {
            var $li = $( '#'+file.id ),
                $percent = $li.find('.progress .progress-bar');

            // 避免重复创建
            if ( !$percent.length ) {
                $percent = $('<div class="progress progress-striped active">' +
                    '<div class="progress-bar" role="progressbar" style="width: 0%">' +
                    '</div>' +
                    '</div>').appendTo( $li ).find('.progress-bar');
            }

            $li.find('p.state').text('上传中');

            $percent.css( 'width', percentage * 100 + '%' );
        });

        uploader.on( 'uploadSuccess', function( file,response) {
            if(response.success)
                ids.push(response.id)
            $( '#'+file.id ).find('p.state').text(response.msg);
        });

        uploader.on( 'uploadError', function( file ) {
            $( '#'+file.id ).find('p.state').text('上传出错');
        });

        uploader.on( 'uploadComplete', function( file ) {
            $('#attach').val(ids.join(','))
            $( '#'+file.id ).find('.progress').fadeOut();
        });

        uploader.on( 'all', function( type ) {
            if ( type === 'startUpload' ) {
                state = 'uploading';
            } else if ( type === 'stopUpload' ) {
                state = 'paused';
            } else if ( type === 'uploadFinished' ) {
                state = 'done';
            }

            if ( state === 'uploading' ) {
                $btn.text('暂停上传');
            } else {
                $btn.text('开始上传');
            }
        });

        $btn.on( 'click', function() {
            if ( state === 'uploading' ) {
                uploader.stop();
            } else {
                uploader.upload();
            }
            return false
        });
     })

</script>
</body>

</html>
